package com.wl.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpSession;

/**
 * 首页
 *
 * @author wl
 */
@Controller
public class IndexController {
  @RequestMapping(method = RequestMethod.GET, value = "/index")
  public String getPage(HttpSession httpSession, Model model) {
    String username = (String) httpSession.getAttribute("username");
    if (username == null) {
      return "redirect:/login";
    } else {
      model.addAttribute("username", username);
      return "index";
    }
  }
}
